package Connection;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import java.util.ArrayList;

/**
 * Klasa zapisuje dane z zadanej tablicy do bazy danych.
 * 
 * @author Katarzyna Tarnowska
 * 
 */
public class Putter {
	public void put(String table, ArrayList<String> al) {
		try {
			Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
			Connection conn = DriverManager.getConnection(
					"jdbc:sqlserver://localhost:1433;databaseName=ABSI",
					"Admin", "Admin");
			Statement statement = conn.createStatement();
			statement.executeUpdate("INSERT INTO [ABSI].[dbo].[" + table
					+ "] (Nazwa, Opis)" + "VALUES ('" + al.get(0) + "','"
					+ al.get(1) + "')");
			conn.close();
		} catch (Exception e) {
			e.printStackTrace();

		}
	}
}
